// import type { User } from "@/types/user";
import { defineStore } from 'pinia';
import { ref } from 'vue';
import { emailCheckAPI, emailLoginAPI, emailRegisterAPI } from '@/api/user';
export const useUserStore = defineStore(
  'qx-user',
  () => {
    const user = ref();
    const setUser = async (data: string) => {
      const result = await emailCheckAPI({ email: data });
      return result;
    };
    const userLogin = async (data: any) => {
      const result = await emailLoginAPI(data);
      return result;
    };
    const userRegister = async (data: any) => {
      const result = await emailRegisterAPI(data);
      return result;
    };
    const delUser = () => {
      user.value = undefined;
    };
    return { user, setUser, delUser, userLogin, userRegister };
  },
  { persist: true }
);
